Skip to main content
Glama

Gitlab Raw API Tool

Easily call any GitLab REST API, customize requests, and filter response fields for debugging or advanced workflows. Streamline integration with GitLab for efficient project and task management.

Instructions

支持自定义调用任意 GitLab REST API,适合调试和高级用法。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataNo请求体
endpointYesGitLab API 路径,如 /projects
fieldsNo需要返回的字段路径数组,支持数组或逗号分隔字符串,用于过滤 API 响应字段。 示例: - ["id", "name", "owner.username"] - "id,name,owner.username" - undefined
methodYesHTTP 方法
paramsNo查询参数

Implementation Reference

  • The execute function implementing the core logic of the Gitlab Raw API Tool: validates args, creates GitLab client, performs API request, optionally filters response fields, and returns JSON or error.
    async execute(args: unknown, context: Context<Record<string, unknown> | undefined>) { const typedArgs = args as { endpoint: string; method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; params?: Record<string, any>; data?: Record<string, any>; fields?: string[]; }; try { const client = createGitlabClientFromContext(context); const response = await client.apiRequest( typedArgs.endpoint, typedArgs.method, typedArgs.params, typedArgs.data ); if (typedArgs.fields) { const filteredResponse = filterResponseFields(response, typedArgs.fields); return { content: [{ type: "text", text: JSON.stringify(filteredResponse) }] } as ContentResult; } return { content: [{ type: "text", text: JSON.stringify(response) }] } as ContentResult; } catch (error: any) { return { content: [ { type: "text", text: `GitLab MCP 工具调用异常:${error?.message || String(error)}` } ], isError: true }; } }
  • Zod schema defining the input parameters for the tool: endpoint (API path), method (HTTP method), optional params, data, and fields for response filtering.
    parameters: z.object({ endpoint: z.string().describe("GitLab API 路径,如 /projects"), method: z.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).describe("HTTP 方法"), params: z.record(z.any()).optional().describe("查询参数"), data: z.record(z.any()).optional().describe("请求体"), fields: createFieldsSchema(), }),
  • Array defining all GitLab tools for FastMCP registration, including GitlabRawApiTool.
    const fastmcpTools = [ GitlabAcceptMRTool, GitlabCreateMRCommentTool, GitlabCreateMRTool, GitlabGetUserTasksTool, GitlabRawApiTool, GitlabSearchProjectDetailsTool, GitlabSearchUserProjectsTool, GitlabUpdateMRTool, ];
  • Core registration loop in registerGitLabToolsForFastMCP that adds GitlabRawApiTool (and others) to the FastMCP server using server.addTool(tool).
    fastmcpTools.forEach(tool => { const standardizedName = toolNameMapping[tool.name as keyof typeof toolNameMapping]; if (shouldRegisterTool(standardizedName as GitLabToolName, options.toolFilter)) { // GitLabTool is now fully compatible with FastMCP's base type, can be registered directly server.addTool(tool); }
  • Name mapping for GitlabRawApiTool to its standardized registered name 'Gitlab_Raw_API_Tool' used in filtering and typing.
    [GitlabRawApiTool.name]: "Gitlab_Raw_API_Tool",

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ZephyrDeng/mcp-server-gitlab'

If you have feedback or need assistance with the MCP directory API, please join our Discord server